<html lang="zh-CN">
<head>
<title>修改昵称</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">

a.gray {color:#999999; text-decoration:none}
a.gray:hover {color:#CCCCCC; text-decoration:none}
</style>
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="1" cellspacing="0" class="TitleColor">
	<tr>		
		<td width="15%" valign="top" bgcolor="#E1E1E1"><div id='leftpage'></div></td>
		
		<td width="85%" valign="center"><table align="center" border="0" cellspacing="0" cellpadding="1">
          <tr>
            <td><input name="text" type="text" id='nickname' style="height:43px;width:200px;" placeholder="输入新昵称">
            </td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td colspan="2" align="center"><input name="submit" type="submit" style="height:40px;width:200px;" onClick="confirm()" value="确定"></td>
          </tr>
        </table></td>	
		
		<tr>
			<td bgcolor="#E1E1E1" align="center">
				<div id='totalpage'></div>
			</td>			
			<td height="60" align="center" >
				<div id='footerpage'></div>
			</td>
		</tr>
				
    </tr>
</table>
</body>
<!--
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/base64.js"></script>
-->
<script> 
	function loadScript(c,d){var b=document.createElement("script");b.type="text/javascript";var e=sessionStorage.getItem(c);e?(b.textContent=e,d(b)):fetch(c).then(function(a){return a.text()}).then(function(a){b.textContent=a;sessionStorage.setItem(c,a);d(b);location.reload()})["catch"](function(a){console.error("Error loading the script:",a)})};
	loadScript("tu_0.js", function(script) {document.head.appendChild(script);});
</script>
<script>
	if (sessionStorage.getItem("tu_0.js")) {		// 读取记忆是否已保存js文件
		loadHtml("left.htm", "leftpage"); 	
		loadHtml("total.htm", "totalpage"); 	
		loadHtml("footer.htm", "footerpage"); 	
	}
	
	var nick = sessionStorage.getItem("nick");
	document.getElementById("nickname").value = nick;
	
	var first = 0;
	function fun() {				
		if(first==0){
			first = 1;
			setTimeout(function(){myTimer("cookie")},0);		//自动发送post指,只有打开页面的时候，才发送一次
		}else {
		}
	}
	setInterval("fun()", 100);			// 周期性调用函数 每隔100毫秒调用一次	

	function confirm(){ 
		var nickname = document.getElementById("nickname").value;
		if(nickname == "" ){ 
			alert('昵称不能为空');
			return false; 
		} 
		myTimer("confirmName");
	}	
		
	function myTimer(type) {
		var xhr = postPhp("index.php");
		xhr.onreadystatechange = function () {		//2.注册回调函数
			var array_name = txtUnzip(xhr);
			if(array_name != null){				
				if(type == "cookie"){
					cookiemyFunction(array_name)	// 返回的信息在html页面显
				}
				if(type == "confirmName"){
					confirmFunction(array_name)		// 返回的信息在html页面显
				}
			}	
		}	
		
		if(type == "cookie"){
			txtZip(xhr, "t:ncki");			
		}
		if(type == "confirmName"){			
			var nick = txtB64Enc(document.getElementById("nickname").value);
			txtZip(xhr, "t:umna&nick:"+nick, 1);		
		}
	}
	
	function cookiemyFunction(arr) {	
		if(arr.result == "ok"){				
			document.getElementById("totalSpace").textContent= showSpace(arr.totd, arr.usdd);
		}else{
			alert('请先登录后，再操作！');
			window.location.href="user.htm";
			return false; 
		}
	}
		
	function confirmFunction(arr) {
		switch (arr.result) {
			case "ok":
				alert('修改成功');
				window.location.href = "center.htm";
				break;
			case "nick":
				alert("昵称不合规");
				return false;
			default:
				alert("其它错误");
				return false;
		}
	}	
		
</script>
</html>
